//
//  MyCollViewController.m
//  testpbl
//
//  Created by 黄权浩 on 15/8/3.
//  Copyright (c) 2015年 黄权浩. All rights reserved.
//

#import "MyCollViewController.h"

@interface MyCollViewController ()
{
    @private
    NSArray *imgarr;
}
@end

@implementation MyCollViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    //测试数据
    imgarr = @[@"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg"];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Scroll
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView == _tab) {
        [_tab2 setContentOffset:CGPointMake(0, scrollView.contentOffset.y)];
    }else {
        [_tab setContentOffset:CGPointMake(0, scrollView.contentOffset.y)];
    }
}

#pragma mark -TAb
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return imgarr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellId = @"cellId";
    ImgViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (!cell) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ImgViewCell" owner:self options:nil];
        cell = nib[0];
    }
    [cell.image setImage:[UIImage imageNamed:imgarr[indexPath.row]]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == _tab) {
        if (indexPath.row%5 == 0) {
            return 200;
        }else if (indexPath.row%5 == 1) {
            return 180;
        }else if (indexPath.row%5 == 2) {
            return 230;
        }else if (indexPath.row%5 == 3) {
            return 250;
        }else {
            return 140;
        }
    }else {
        if (indexPath.row%5 == 0) {
            return 140;
        }else if (indexPath.row%5 == 1) {
            return 250;
        }else if (indexPath.row%5 == 2) {
            return 150;
        }else if (indexPath.row%5 == 3) {
            return 170;
        }else {
            return 240;
        }
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
